package com.gec.controller;

import com.gec.dao.BookDao;
import com.gec.dao.BookDao1;
import com.gec.entity.Book;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 根据id来查询客房信息
 */
@WebServlet("/GetBookByIdServlet1")
public class GetBookByIdServlet1 extends HttpServlet {

    /**
     * 1、	获取修改的客房信息 根据id去获取要修改的客房 显示到一个新的页面去
     * @param request
     * @param response
     * @throws ServletException
     * @throws IOException
     */
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        //获取客房编号

        //GetBookByIdServlet?id=${book.id }？可以在url地址中携带参数来请求服务器
        String id = request.getParameter("id");
        //调用根据客房编号查询客房的方法
        BookDao bookDao = new BookDao();
        //调用根据编号查询客房的方法
        Book book = bookDao.getBookById(id);
        //将客房信息传递到修改客房信息页面
        request.setAttribute("book",book);
        request.getRequestDispatcher("updateList1.jsp").forward(request,response);
    }
}
